package com.tgy.controller;

import com.tgy.entity.Dept;
import com.tgy.service.DeptClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

/***
 * @ClassName: ConsumerController
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 9:46 2022/1/11
 * @version : V1.0
 */
@RestController
@RequestMapping("/consumer")
@Slf4j
public class ConsumerController {
    @Resource
    DeptClientService service;

    @GetMapping("/id/{id}")
    public Dept getById(@PathVariable(name = "id") Long id) {
        return  service.id(id);
    }

    @RequestMapping("/test")
    public String test() {
        return service.test();
    }

    @RequestMapping("/all")
    public List<Dept> all() {
        System.out.println("进入消费者");
        return service.all();
    }

    @PostMapping("/list")
    public List<Dept> list(@RequestBody Dept dept) {
        return service.list(dept);
    }

    @PostMapping("/add")
    public Boolean add(@RequestBody Dept dept){
        return service.add(dept);
    }

    @PostMapping("/upd")
    public Boolean upd(@RequestBody Dept dept){
        return service.upd(dept);
    }

    @GetMapping("/delR/{id}")
    public Integer delR(@PathVariable(name = "id", required = true) Long id ){
        return service.delR(id);
    }

    @GetMapping("/del")
    public Integer del(@RequestParam(name ="id") Long id ){
        return service.del(id);
    }
}
